package com.wiscamp.ninechapters.problems.domain.models.sheets;

import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.wiscamp.ninechapters.ddd.AggregateRoot;
import com.wiscamp.ninechapters.problems.enums.SheetStatus;
import com.wiscamp.ninechapters.problems.enums.SheetTypes;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collection;

/**
 * 答题卡
 */
@Data
public class Sheet implements AggregateRoot {

    /**
     * 答题卡编号
     */
    private long sheetId = 0;

    private int sheetTypeId = 0;

    /**
     * 用户编号
     */
    private long userId = 0;

    /**
     * 开始时间
     */
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime beginTime;

    /**
     * 结束时间
     */
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    private LocalDateTime endTime;

    /**
     * 习题集编号
     */
    private long setId = 0;

    /**
     * 分数
     */
    private double gainScore = 0;

    private int sheetStatusId = 0;

    /**
     * 任务编号
     */
    private long taskId = 0;

    /**
     * 答题卡明细列表
     */
    private Collection<SheetDetail> details = new ArrayList<>();

    public SheetTypes getSheetType() {
        return SheetTypes.valueOf(sheetTypeId);
    }

    public SheetStatus getSheetStatus() {
        return SheetStatus.valueOf(sheetStatusId);
    }
}
